<template>
  <div class="classifyBox">
    <div class="navTitle">
      <span>{{cats.name}}</span>
      <span class="iconfont icon-weibiaoti-13"></span>
    </div>
    <div class="classifyContent">
      <goodsList
        :propsData="propsData"
        v-if="propsData.params.styleType == 1"
        :goodsList="cats.goods_list"
      ></goodsList>
      <div class="navList" v-if="propsData.params.styleType == 6">
        <div class="navItem" v-for="(item,index) in cats.children" :key="index">
          <img
            src="@/assets/images/diy/default_img.png"
            alt=""
            v-if="item.pic_url == ''"
          />
          <img
            :src="item.pic_url"
            alt=""
            v-else
          />
          <span>{{item.name}}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import goodsList from "../goodsList/index.vue";
export default {
  props: {
    propsData: {
      type: Object,
      default: {},
    },
    cat: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  components: {
    goodsList,
  },
  data() {
    return {
      catObj: {
        name: "常用分类",
        children: [
          { name: "平板电脑", pic_url: "", goods_list: [] },
          { name: "平板电脑", pic_url: "", goods_list: [] },
          { name: "平板电脑", pic_url: "", goods_list: [] },
          { name: "平板电脑", pic_url: "", goods_list: [] },
        ],
      },
    };
  },
  computed: {
    cats() {
      let obj =
        this.cat && this.cat.name ? this.cat : this.catObj;
      return obj;
    },
  },
  mounted() {
    console.log(this.cat,"cat111");
  },
};
</script>

<style lang="scss" scoped>
.classifyBox {
  width: 100%;
  .navTitle {
    display: flex;
    align-items: center;
    width: 100%;
    justify-content: space-between;
    font-size: 14px;
    color: #262626;
    font-family: PingFang SC;
    font-weight: 600;
    padding-bottom: 8px;
    .iconfont {
      font-weight: normal;
      font-size: 12px;
      color: #888;
    }
  }
  .navList {
    padding-top: 8px;
    display: flex;
    flex-wrap: wrap;
    .navItem {
      display: flex;
      flex-direction: column;
      align-items: center;
      font-size: 12px;
      color: #808080;
      font-family: PingFang SC;
      margin-bottom: 15px;
      margin-right: 16px;
      img {
        width: 70px;
        height: 70px;
        border-radius: 5px;
        margin-bottom: 7px;
      }
    }
    .navItem:nth-child(3n) {
      margin-right: 0;
    }
  }
}
</style>